<?php
$control->renderView('weChatShare');
//获取当前user信息
$userCooker = new BAUserCooker();
$userInfo = $userCooker->getUserInfo();
//var_dump($userInfo);
$familyNameAttr = '';
$surNameAttr = '';
if ($userInfo->getItem('familyName') != NULL)
    $familyNameAttr = $userInfo->getItem('familyName')->getValue();
if ($userInfo->getItem('surName') != NULL)
    $surNameAttr = $userInfo->getItem('surName')->getValue();
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/wei_webapp_new.css' ?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/wei_dialog.css' ?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/common.css' ?>">

<!-- ajax加载页面时弹出加载旋转gif图 -->
<style>
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<style type="text/css">
    /*	.main{width: 350px;height: 100px;background-color: white;padding-top: 8px;}
            .tu{width:96px;height: 74px;float: left;margin-left: 8px;}
            .wen{width: 200px;float: left;margin-left: 10px;}
            .wen p {line-height: 28px;}*/
    #imgGo {overflow: hidden; position: relative;  padding: 0;margin: 0 auto;}
    #imgGo ul {overflow: hidden; position: absolute; top: 0; left: 0; margin: 0; padding: 0;}
    #imgGo ul li {overflow: hidden; float: left; margin: 0; padding: 0;}
    #imgIndex {overflow: hidden; position: absolute; bottom: 0; margin: 0; padding-right:50%; width: 100%; height: 12%; text-align: center;}
    #imgIndex span {display: inline-block; width: 10px; height: 10px; margin-right: 3%; border-radius: 100%; background-color: #BDBDBD;cursor: pointer; opacity: 0.4;}

    .shadow{height: 60px;width: 290px;background-color: black;border-radius: 5px;opacity:0.45;}
    .img{position:absolute;top: 180px;left: 50%;margin-left:-146px;}
    img.s{border:0;height: 100px;width:100%;}
    img.l{border:0;height: 60px;width:60px;display:inline-block;margin-bottom:10px;}
    .enableApply{
        padding-top: 5px;
        line-height: 32px;
        text-align: left;
        color: #373B3E;
        font-size: 14px;
        padding-left: 21px;
        font-weight: bold;
    }
</style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="<?php echo Yii::app()->request->baseUrl . '/images/ajax-loader.gif' ?>" class="ajax-loader">
</div>


<div id="page_card" class="div-body">

    <div id="mappContainer">
        <div class="inner root" style="height: 519px;">
            <div class="card" style="background:url(<?php echo Yii::app()->request->baseUrl . '/images/BWeMember/wei_webapp_new/card_bk_1.png' ?>) no-repeat 0 0;-webkit-background-size:267px 159px;background-size:267px 159px;" data-card-type="0">
                <img src="<?php echo Yii::app()->request->baseUrl . '/images/BWeMember/weixin_shop_logo/2543529110_card_170_170.png' ?>" class="logo"> 
                <h1></h1>
                <strong class="pdo verify">
                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;"><?php echo'会员名'; ?></em><?php echo $familyNameAttr . $surNameAttr; ?></span>
                </strong>
            </div>
            <?php
            if (!$cardView && !$applyListCount) {//没有卡，也没有可以领取的卡
                ?>
                <p class="enableApply" style="font-weight: normal;margin-top: 15px;padding: 5px;font-weight: normal;">尊敬的客户，您目前没有领取会员卡，感谢您的关注！</p>
                <?php
            }
            ?>
            <?php if ($cardView) { ?>
                <h2 class="enableApply">已领取的会员卡</h2>
                <ul class="round"> 
                    <?php
                    $cardCooker = new BAMemberCardCooker();
                    $userCooker = new BAUserCooker();
                    $permitCooker = new BAPermitCooker();
                    $memberPointCooker = new BAMemberPointCooker();
                    $memberPoint = '';
                    foreach ($cardView as $id => $list) {//这个地方应该用卡的方式显示，而不是列表方式显示
                        $userInfoId = $list->getItem('userInfoId')->getValue();
                        $cardId = $list->getItem('cardId')->getValue();
                        $cardTypeId = $list->getItem('cardTypeId')->getValue();
                        $permitId = $list->getItem('permitId')->getValue();
                        $cardType = $cardCooker->getCardType($cardTypeId);
                        $userInfo = $userCooker->getUserInfo($userInfoId);
                        $oPermit = $permitCooker->getPermit($permitId);
                        //$card = $cardCooker->getCard($cardId);
                        $cardTypeAlias = $cardType->getValue();
                        $after10year = strtotime("+10 years");
                        $expire = $oPermit->getItem('expireTime')->getValue();
                        if ($expire > $after10year) {
                            $expireTime = '一直有效';
                        } else {
                            $expireTime = date('Y/m/d:H', $expire);
                        }

                        $name = '---';
                        if ($userInfo != NULL) {
                            if ($userInfo->getItem('familyName') != NULL) {
                                $name = $userInfo->getItem('familyName')->getValue();
                            }
                            if ($userInfo->getItem('surName') != NULL) {
                                $surName = $userInfo->getItem('surName')->getValue();
                                if ($name == '---')
                                    $name = $surName;
                                else {
                                    $name.=$surName;
                                }
                            }
                        }
                        $preCardType = $cardCooker->getPreCardTypeFromCardType($cardType);
                        if ($preCardType == 'memberPointCard') {
                            $memberPointCooker = new BAMemberPointCooker();
                            //get memberPoint Type
                            $memberPointTypeId = $cardCooker->getCardTypeAttribute('memberPointType', $cardType);

                            $memberPointType = $memberPointCooker->getMemberPointType($memberPointTypeId);

                            //get memberPointAccount
                            $mpAccount = $memberPointCooker->getMemberPointAccountByUser($memberPointType);

                            if ($mpAccount != NULL) {
                                $accountData = $mpAccount->getItemsInArray();
                                $memberPoint = $accountData['memberPoint'];
                            }
                        }
                        ?>
                        <li style="margin-bottom: 10px;margin-top: 10px;">
                            <div class="card" style="-webkit-background-size:267px 159px;height: 50px;width: 100%;" data-card-type="0">
                                <strong class="pdo verify" style="top: 10px;">
                                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;float: left;margin-left: 10px;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">会员卡类型</em><?php echo $cardTypeAlias; ?></span>
                                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;margin-right: 10px;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">卡号</em><?php echo $cardTypeId; ?></span>
                                </strong>
                            </div>
                        </li>
                    <?php } ?>
                </ul>
                <?php
            }
            ?>
            <?php
            if ($applyListCount) {//有可以申请的会员卡
                ?>
                <p class="enableApply" style="font-weight: normal;">尊敬的客户，您有<a style="font-weight: bold;"><?php echo $applyListCount . '张'; ?></a>可以领取的会员卡，点击以下按钮领取会员卡！</p>
                <ul  style="text-align: center;"> <!--class="round"-->
                    <?php
                    $ajaxScript5 = $control->getAjaxScript('showUserCardApplyListInMobile', array(
                        'cooker' => 'BAMemberCard@showUserCardApplyList',
                    ));
                    ?>
                    <a href="#" onclick="<?php echo $ajaxScript5; ?>" class="btn btn-success">领取会员卡</a>
                </ul>
                <?php
            }
            ?>
        </div>
        <?php
        $returnUrl = $control->getAjaxScript('返回会员卡页', array(
            'cooker' => 'BAMemberCard@showUserCardHome',
        ));
        ?>
        <div class="footFix" id="footReturn"><a  href="javascript:void(0)" onclick="<?php echo $returnUrl; ?>"><span>返回会员卡页</span></a></div>
    </div>

<!--    <div id="mCopyright" style="height: 33px;">
        <div class="mcrInn">
            <h1>比邻平台</h1>
        </div>
    </div>-->

</div>
